package com.mfp.java.testYou.db;

import com.mfp.java.testYou.core.utils.Utils;

public class DataAccessFactory {

	private DataAccessFactory() {
	}

	public static DataAccessObject createDAO() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
		String className = Utils.readConfig("config.properties", "db.dao.class");
		Object o = Class.forName(className).newInstance();
		if (o instanceof DataAccessObject) {
			DataAccessObject dao = (DataAccessObject) o;
			return dao;
		} else {
			throw new IllegalStateException("Configured class does not implement the DAO interface");
		}
	}

}
